player.body.moveFrom(1000, 150, 90)
player.body.moveFrom(1000, 150, 90)
player.body.moveFrom(1000, 150, 90)

// async function moveByOrder () {
//   await moveLeft()
//   await moveLeft()
//   await moveLeft()
// }

// function moveLeft () {
//   let p = new Promise((resolve, reject) => {
//     setTimeout(() => {
//       console.log('left')
//       resolve('left')
//     }, 1000)
//   })
//   return p
// }

// moveByOrder()
var Interpreter = require('js-interpreter')

function init (interpreter, scope) {
  var wrapper = function (d, next) {
    setTimeout(function () {
      next()
    }, d)
  }
  interpreter.setProperty(
    scope,
    'wait',
    interpreter.createAsyncFunction(wrapper)
  )

  wrapper = function () {
    console.log('!')
  }
  interpreter.setProperty(
    scope,
    'show',
    interpreter.createAsyncFunction(wrapper)
  )
}

let interpreter = new Interpreter(
  `wait(2000);
wait(1000)`,
  init
)

interpreter.run()
